
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 06/11/2014 12:05:34
-- Generated from EDMX file: C:\Users\Ruben\Documents\Visual Studio 2013\Projects\SECOMPV4\SECOMPV2\Model1.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [SECOMPV2];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_GroepSpecificatie]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Specificaties] DROP CONSTRAINT [FK_GroepSpecificatie];
GO
IF OBJECT_ID(N'[dbo].[FK_SpecificatieValue]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Waardes] DROP CONSTRAINT [FK_SpecificatieValue];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Groeps]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Groeps];
GO
IF OBJECT_ID(N'[dbo].[Specificaties]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Specificaties];
GO
IF OBJECT_ID(N'[dbo].[Waardes]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Waardes];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Groeps'
CREATE TABLE [dbo].[Groeps] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Naam] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Specificaties'
CREATE TABLE [dbo].[Specificaties] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Naam] nvarchar(max)  NOT NULL,
    [Type] nvarchar(max)  NOT NULL,
    [Groep_Id] int  NOT NULL
);
GO

-- Creating table 'Waardes'
CREATE TABLE [dbo].[Waardes] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Naam] nvarchar(max)  NOT NULL,
    [Specificatie_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'Groeps'
ALTER TABLE [dbo].[Groeps]
ADD CONSTRAINT [PK_Groeps]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Specificaties'
ALTER TABLE [dbo].[Specificaties]
ADD CONSTRAINT [PK_Specificaties]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Waardes'
ALTER TABLE [dbo].[Waardes]
ADD CONSTRAINT [PK_Waardes]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [Groep_Id] in table 'Specificaties'
ALTER TABLE [dbo].[Specificaties]
ADD CONSTRAINT [FK_GroepSpecificatie]
    FOREIGN KEY ([Groep_Id])
    REFERENCES [dbo].[Groeps]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GroepSpecificatie'
CREATE INDEX [IX_FK_GroepSpecificatie]
ON [dbo].[Specificaties]
    ([Groep_Id]);
GO

-- Creating foreign key on [Specificatie_Id] in table 'Waardes'
ALTER TABLE [dbo].[Waardes]
ADD CONSTRAINT [FK_SpecificatieWaarde]
    FOREIGN KEY ([Specificatie_Id])
    REFERENCES [dbo].[Specificaties]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SpecificatieWaarde'
CREATE INDEX [IX_FK_SpecificatieWaarde]
ON [dbo].[Waardes]
    ([Specificatie_Id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------